
#include "stdafx.h" 
#include "MainFrm.h" 
#include "resource.h"

CMainFrame::CMainFrame()  
{
}

CMainFrame::~CMainFrame()
{
}
    
LRESULT CMainFrame::OnCommand(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled)
{ 
	printf("OnCommand: wParam= x%x(%d)\n",wParam,wParam); 
	WORD wID = LOWORD(wParam);
	pvViewToolBar(wID);
	pvFileExit(wID);
	return 0;
}


LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	printf("OnCreate: \n"); 

	HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
	// attach menu
	HMENU hMenu = GetMenu();
	m_CmdBar.AttachMenu(hMenu);
	// load command bar images
//	m_CmdBar.LoadImages(IDR_MAINFRAME);
	// remove old menu
	SetMenu(NULL);

 	HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, 101, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);
	
 	CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);
	AddSimpleReBarBand(hWndCmdBar);
 	AddSimpleReBarBand(hWndToolBar, NULL, TRUE);

	
	CreateMDIClient(); 
	m_MenuControl.Install(m_CmdBar, m_hWndMDIClient);
	m_CmdBar.SetMDIClient(m_hWndMDIClient);
	UIAddToolBar(hWndToolBar);
	UISetCheck(ID_VIEW_TOOL_BAR, true);
	
	UISetCheck(ID_FILE_NEW, 1);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);
	 
	pvMyTitle();

	CreateSimpleStatusBar("");
	
	m_SBCtrl.SubclassWindow(m_hWndStatusBar);
	int arrParts[] =
	{
		    ID_DEFAULT_PANE,
			ID_AOI_PANE,
			ID_POS_PANE,
			ID_VALUE_PANE, 
			ID_FPS_DISPLAYED_PANE
	};
	m_SBCtrl.SetPanes(arrParts, sizeof(arrParts) / sizeof(int), false);


	return 0;
}
 
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{ 
//	printf("CMainFrame::PreTranslateMessage: \n");

	if(CMDIFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
		return TRUE;
	
 	return FALSE;
}

BOOL CMainFrame::OnIdle()
{ 
//	printf("OnIdle: \n");
	return FALSE;
}
